<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

namespace backend\controllers;

use yii\web\Controller;
use backend\models\LoginForm;
use Yii;
/**
 * Description of LoginController
 *
 * @author zhige
 */
class LoginController extends Controller{
    //put your code here
    public function actionIndex(){
        
//        Yii::$app->session->remove(LoginForm::BACKEND_ID);
//        Yii::$app->session->remove(LoginForm::BACKEND_USERNAME);
        
        $model = new LoginForm();
        if(Yii::$app->request->isPost  
                && $model->load(Yii::$app->request->post()) 
                && $model->validate() && $model->login()){
           return $this->redirect(['site/index']);
        }
        return $this->renderPartial('index',[
            'model'=>$model,
        ]);
    }
    
    public function actions(){
        
        return [
            'captcha' => [
                'class' => 'yii\captcha\CaptchaAction',
                'maxLength' => 4,
                'minLength' => 4,
                'width' => 80,
                'height' => 40
            ]
        ];
    }
    
    
}
